Skip to content

fix: record non-stream usage for provider-native responses#1912

Closed
nguyenha935 wants to merge 1 commit into
decolua:masterfrom
nguyenha935:fix/nonstream-usage-history
Closed

fix: record non-stream usage for provider-native responses#1912
nguyenha935 wants to merge 1 commit into
decolua:masterfrom
nguyenha935:fix/nonstream-usage-history

Conversation

@nguyenha935

Copy link
Copy Markdown
Contributor

Summary

  • Expand non-stream usage extraction to support provider-native response shapes such as Ollama, Kiro, CommandCode, nested OpenAI Responses usage, and nested Gemini usage metadata.
  • Estimate missing prompt tokens from the original request when a provider reports output tokens only, preserving an estimated flag for visibility.
  • Preserve cache/reasoning usage metadata when saving usage history so Recent Requests and cost accounting have the same token context.

Test Plan

  • ./node_modules/.bin/vitest run --config vitest.config.js --reporter=verbose unit/nonstream-usage-extraction.test.js unit/usage-concern.test.js
  • npm run build

ozkancan-apk added a commit to ozkancan-apk/9routerFullFree that referenced this pull request Jun 22, 2026
Applied 12 upstream decolua/9router PRs (cherry-pick pattern):

Bugfix PRs:
- decolua#1902 init params in transformRequest
- decolua#1986 fix gemini-tts 502 models/undefined
- decolua#1958 fix antigravity image-to-image editing
- decolua#1987 fix TTS minimax voices exposure
- decolua#1898 fix usage duplicate zero-token entries
- decolua#1955 fix kiro context window for claude-opus-4.8
- decolua#1935 fix opencode-go Kimi temperature (strip params + tests)
- decolua#1919 fix quota collapse rows, sort by remaining

Feature/improvement PRs:
- decolua#1959 improve antigravity client fingerprint
- decolua#1912 fix non-stream usage for provider-native responses
- decolua#1973 fix headroom log skip diagnostics

Migration fix:
- Added combo copy from original 9router DB (3 combos: best, free-best, claude-mem)
- uncloseai: removed duplicate model entry (v0.5.13 regression)

Note: All PRs verified clean apply + build green.
2 pre-existing snapshot failures unrelated to changes.
@nguyenha935

Copy link
Copy Markdown
Contributor Author

Superseded by #1994. The new PR keeps the Recent Requests UI filtering clean, records token-bearing CLI usage through the usageHistory path, avoids duplicate stream usage rows, and also fixes Responses API field cleanup for OpenCode Go GLM.

@nguyenha935 nguyenha935 deleted the fix/nonstream-usage-history branch June 22, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant